<template>
  <div class="infinite-container">
    <div class="lefttime">
      <span v-if="qData.payRemainingSeconds">
        剩余支付时间：
        <TimeCountDown :leftTime="qData.payRemainingSeconds" :data-index="1" />
      </span>
      <span v-else-if="qData.onlineConsultAppointmentRecordStatus == 0">订单支付超时</span>
      <span v-else>{{qData.onlineConsultAppointmentRecordStatus | filterMedicalStatus}}</span>
    </div>
    <div class="pageContent">
      <div class="fcon">
        <div class="flex flex_between">
          <span>订单时间</span>
          <span>{{qData.ask.createTime}}</span>
        </div>
        <div class="item-con">
          <div>
            <div class="item-con-mid">
              <div>
                <img v-lazy="doctor.header" class="doctor-image" alt />
              </div>
              <div>
                <h3>
                  <p>{{qData.ask.doctorName}}</p>
                  <span>{{qData.ask.doctorJobTitle }}</span>
                  <span>{{qData.ask.departmentName}}</span>
                </h3>
              </div>
              <div></div>
            </div>
          </div>
        </div>
      </div>
      <div class="mt10"></div>
      <div class="bgwhite" id="consultTypeFee">
        <mu-list>
          <mu-list-item>
            <span slot="left">{{qData.ask.consultType | getConsultType}}</span>
            <span slot="right" class="feeText">{{qData.ask.cost | fixedMoney}}</span>
          </mu-list-item>
          <mu-divider />
        </mu-list>
      </div>
      <div class="bgwhite mt10">
        <ul class="infoList">
          <li class="flex flex_between">
            <span>问诊人</span>
            <span>{{qData.ask.personName}}</span>
          </li>
          <li class="flex flex_between" v-if="qData.ask.consultType == 'tel'">
            <span>联系号码</span>
            <span>{{qData.ask.consultAskTelephone}}</span>
          </li>
          <li class="flex flex_between">
            <span>咨询时间</span>
            <span>{{qData.ask.createTime && qData.ask.createTime.slice(0,11)}} {{qData.timeFlag | getTimeFlag}}</span>
          </li>
        </ul>
      </div>
      <div class="mt10"></div>
      <left-border-title :title="'病情描述'"></left-border-title>
      <div class="scon bgwhite">{{qData.ask.question || ''}}</div>
      <div class="mt10"></div>
      <left-border-title :title="'病情照片'"></left-border-title>
      <ul class="fileHandler flex wrap bgwhite">
        <li v-for="(item,index) in images" :key="index">
          <img :src="item.fileUrl" alt />
        </li>
        <div class="t3 mt10" v-if="images.length == 0">没有图片</div>
      </ul>
    </div>

    <div class="bottomHandler flex" v-if="pageAction == '待支付'">
      <div>
        <mu-raised-button label="取消问诊" fullWidth @click="goCancel(qData.ask.consultId)"></mu-raised-button>
      </div>
      <div>
        <mu-raised-button label="去支付" fullWidth primary :disabled="disabled" @click="goToPay()"></mu-raised-button>
      </div>
    </div>
    <div class="bottomHandler" v-else>
      <mu-raised-button label="再次咨询" class="submit-btn" fullWidth primary @click="goDoctorPage()"></mu-raised-button>
    </div>
  </div>
</template>

<script>
import leftBorderTitle from "../../components/leftBorderTitle.vue";
import TimeCountDown from "../../components/TimeCountDown.vue";
import { commonAjaxJson, RESTFUL_API } from "../../api/api";
export default {
  data() {
    return {
      qData: { ask: {}, schedulingDate: "" },
      images: [],
      doctor: {},
      dialog: false,
      disabled: false,
      param: {
        consultId: ""
      },
      param1: {
        consultId: 0,
        cancelType: 2
      },
      pageAction: ""
    };
  },
  components: {
    leftBorderTitle,
    TimeCountDown
  },

  mounted() {
    if (this.$route.query.status == 10) {
      this.pageAction = "待支付";
    } else if (this.$route.query.status == 14) {
      this.pageAction = "已关闭";
    }
    this.getOrderDetail();
  },
  methods: {
    goToPay() {
      this.$router.push("/queryOnline/confirmPay?cid=" + this.$route.query.cid);
    },
    goDoctorPage() {
      this.$router.push(
        `/queryOnline/doctorDetail?docid=${this.qData.ask.doctorId}&departmentId=${this.qData.ask.departmentId}`
      );
    },
    goCancel(cid) {
      this.$router.push({
        path: "/queryHistory/cancelReason",
        query: {
          cid: cid
        }
      });
    },
    confirmDelete() {
      this.cancelQuery();
    },
    getOrderDetail() {
      if (!this.$route.query.cid) {
        this.$store.commit("UPDATE_TOAST", {
          message: "页面错误!"
        });
        return;
      }
      this.param.consultId = this.$route.query.cid;
      commonAjaxJson(RESTFUL_API.queryDetail, this.param, true).then(res => {
        const {code, data} = res.data
        if (code == 200) {
          // 详情没有，需要列表传入onlineConsultAppointmentRecordStatus
          data.onlineConsultAppointmentRecordStatus = data.ask.onlineConsultAppointmentRecordStatus
          
          this.qData = res.data.data;
          this.images = res.data.data.listAttr;
          this.doctor = res.data.data.doctor;
        } else {
          this.$store.commit("UPDATE_TOAST", {
            message: "服务器内部错误!"
          });
        }
      });
    }
  }
};
</script>

<style lang="less" scoped>
@import "../../common/css/flex.css";
@import "../../common/css/component";

.infinite-container {
  padding-bottom: 30px;
  @{deep} .mu-item-left img {
    width: 30px;
    height: 30px;
  }
  @{deep} .mu-item.show-left {
    padding-left: 60px;
  }
  @{deep} .mu-item-title {
    color: #333;
  }
  @{deep} .mu-item-text {
    color: #ccc;
  }
  @{deep} .mu-item {
    min-height: 44px;
  }
  .feeText {
    font-size: 20px;
    color: #ff6600;
  }
  .lefttime {
    width: 100%;
    height: 35px;
    line-height: 35px;
    text-align: center;
    font-size: 14px;
    color: #ff6600;
    background: #fffdce;
    border-bottom: 1px solid #e8e8e8;
  }
  .item-con {
    background: #fff;
    padding: 15px 0 15px 0px;
    > div {
      width: 100%;
      position: relative;
    }
    &-mid {
      display: table;
      width: 100%;
      > div:first-child {
        display: table-cell;
        vertical-align: middle;
        width: 52px;
        > img {
          width: 52px;
          height: 52px;
          vertical-align: middle;
        }
      }
      > div:nth-child(2) {
        display: table-cell;
        padding-left: 15px;
        vertical-align: middle;
        > h3 {
          font-size: 16px;
          color: #333;
          font-weight: normal;
          font-size: 14px;
          padding-bottom: 2px;
          > span:first-child {
            font-size: 16px;
            padding-right: 10px;
          }
        }
        > div {
          font-size: 14px;
        }
        > div:first-of-type {
          display: flex;
          align-items: center;
          > img {
            width: 15px;
            height: 15px;
            margin-right: 10px;
          }
          color: #999;
        }
      }
      > div:last-child {
        vertical-align: middle;
        display: table-cell;
        width: 1%;
        white-space: nowrap;
        font-size: 20px;
        color: #ff6600;
        text-align: right;
      }
    }
  }
  .fcon {
    padding: 0px 15px 0px 15px;
    background: #fff;
    border-bottom: 1px solid #e8e8e8;
    > div:first-child {
      width: 100%;
      height: 40px;
      line-height: 40px;
      border-bottom: 1px solid #e8e8e8;
      font-size: 14px;
      color: #666;
    }
  }
  .scon {
    border-top: 1px solid #e8e8e8;
    width: 100%;
    padding: 15px;
    color: #666;
    font-size: 14px;
  }
  .tcon {
    border-top: 1px solid #e8e8e8;
    width: 100%;
    padding: 15px;
    color: #666;
    font-size: 14px;
  }
  .fileHandler {
    border-top: 1px solid #e8e8e8;
    padding: 0px 15px;
    padding-bottom: 20px;
    li {
      position: relative;
      width: 25%;
      height: 25%;
      display: flex;
      align-items: center;
      justify-content: center;
      margin-top: 20px;
      img {
        width: 80%;
        height: 80%;
        border-radius: 4px;
      }
    }
  }
  .lcon {
    width: 100%;
    padding-top: 10px;
    text-align: center;
    @{deep}.mu-raised-button {
      width: 80%;
      height: 44px;
      margin-top: 20px;
    }
    @{deep}.mu-raised-button-secondary {
      color: #f24242;
      border: 1px solid #f24242;
      background: #fff1f1;
    }
  }
}
.infoList {
  padding: 0 10px;
  li {
    padding: 8px 0;
  }
}
.bottomHandler {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  > div {
    width: 50%;
    height: 46px;
  }
}
.pageContent {
  position: absolute;
  width: 100%;
  top: 35px;
  bottom: 46px;
  overflow-y: scroll;
}
</style>
<style lang="less">
#consultTypeFee {
  .mu-item-left {
    width: 80px;
  }
}
.bottomHandler {
  .mu-raised-button {
    height: 100%;
  }
}
</style>
